#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author:Taotie Ren
#
# 函数
#     1.def
#     2.名字
#     3.函数体
#     4.返回值
#     ===》定义函数，函数体不执行


"""
def SendMail():
    try:
        import smtplib
        from email.mime.text import MIMEText
        from email.utils import formataddr

        msg = MIMEText('邮件内容','plain','utf-8')
        msg['From'] = formataddr(["taotieren",'admin@taotieren.com'])
        msg['To'] = formataddr(["taotieren",'taotieren@vip.qq.com'])
        msg['Subject'] = "主题"

        server = smtplib.SMTP("smtp.qq.com",25)
        server.login("admin@taotieren.com","password")
        server.sendmail('admin@taotieren.com',['taotieren@vip.qq.com'],msg.as_string())
        server.quit()

    except:
        #发送失败
        return False
    else:
        #发送成功
        return True

ret = SendMail()

print(ret)
if ret == True:
    print('发送成功')
else:
    print('发送失败')

"""
#
# def f1():
#     print(123)
#     #在函数中，一旦执行return，函数执行过程立即终止
#     return "111"
#     print(456)
#
# r = f1()
# print(r)

# def f2():
#     print(123)
#
# r = f2()
# print(r)


"""
# 形式参数
def SendMail(addr):
    try:
        import smtplib
        from email.mime.text import MIMEText
        from email.utils import formataddr

        msg = MIMEText('邮件内容','plain','utf-8')
        msg['From'] = formataddr(["taotieren",'admin@taotieren.com'])
        msg['To'] = formataddr(["taotieren",'taotieren@vip.qq.com'])
        msg['Subject'] = "主题"

        server = smtplib.SMTP("smtp.qq.com",25)
        server.login("admin@taotieren.com","password")
        server.sendmail('admin@taotieren.com',['addr'],msg.as_string())
        server.quit()

    except:
        #发送失败
        return False
    else:
        #发送成功
        return True

while True:
    em = input("请输入邮箱地址：")

    # 实际参数
    ret = SendMail(em)
    if ret == True:
        print("发送成功")
    else:
        print("发送失败")
"""

'''
#普通参数
def Send(xxoo,content):
    print("发送邮件成功",xxoo,content)
    return True

while True:
    em = input("请输入邮箱地址：")

    # 实际参数
    ret = Send(em,"NB")
    if ret == True:
        print("发送成功")
    else:
        print("发送失败")
'''

'''
#默认参数 
#默认参数必须要放到参数列表的后面
def Send(xxoo,content,xx = "OK"):
    print("发送邮件成功",xxoo,content,xx)
    return True

Send('A','B')
Send('A','B','C')
'''
'''
#指定参数
def Send(xxoo,content,xx = "OK"):
    print("发送邮件成功",xxoo,content,xx)
    return True

Send('A','B')
Send(xx = 'A',xxoo = 'B',content = 'C')
'''

# #* 动态参数 默认将出入的参数，全部不放在元组中
#
# def f1(*args):
#     print(args,type(args))
#
# f1(11,2,"A","dd")
#
# li = [11,2,"A","dd"]
# f1(li)
# f1(*li)
#
# li = "ABCD"
# f1(*li)
#
#
#** 动态参数  默认将出入的参数，全部不放在字典中
#
# def f1(**args):
#     print(args,type(args))
#
# f1(n1 = "ABCD",n2 = 18)
#
# dic = {'k1':"v1",'k2':"v2"}
# f1(kv = dic)
# f1(**dic)

# 5.万能参数 *args **kwargs

# def f1(*args,**kwargs):
#     print(args,type(args))
#     print(kwargs,type(args))
#
# f1(11,22,33,44,k1 = "v1",k2 = "v2")


# str.format()
# str format 格式化输出
# %s %d

# s1 = "I am {0},age {1}".format("Tom",18)
# print(s1)
# s = "I am {0},age {1}".format(*["Tom",18])
# print(s)
#
# s = "I am {name},age {age}".format(name = "Tom",age = 18)
# print(s)
#
# dic ={'name':"Tom","age":18}
# s1 = "I am {name},age {age}".format(**dic)
# print(s1)
#
#


#后面的f1
# def f1(a1,a2):
#     return a1+a2
#
# def f1(a1,a2):
#     return a1*a2
#
# ret = f1(8,8)
# print(ret)


#传递的是引用
# def f1(a1):
#     a1.append(999)
#
# li = [11,22,33,44]
# f1(li)
#
# print(li)

# 全局变量 所有的作用域都可以读
#对全局变量进行重新赋值 需要global
#特殊： 列表字典 可以修，不可重重新赋值
#全局变量用大写
NAME = "Tom"
def f1():
    # global NAME #表示 name是全局变量
    # NAME = "123"
    age = 18
    print(age,NAME)


def f2():
    age = 16
    print(age, NAME)

f1()
f2()